/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// pbmpconv.hpp - BMP decompressor object.
//
// Author: Kenneth G. Maxwell
//
//
// Copyright (c) 1997-2000 Swell Software 
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
//
//
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifndef _PEGBMPCONVERT_
#define _PEGBMPCONVERT_

typedef struct 
{
    PEGUSHORT   id;
    PEGULONG    file_size;
    PEGUSHORT   reserved[2];
    PEGULONG    image_offset;
    PEGUSHORT   header_size;
    PEGUSHORT   not_used;
    PEGULONG    xres;
    PEGULONG    yres;
    PEGUSHORT   numplanes;
    PEGUSHORT   bits_per_pix;
    PEGULONG    compression;
    PEGULONG    bit_map_size;
    PEGULONG    hor_res;
    PEGULONG    vert_res;
    PEGULONG    number_of_colors;
    PEGULONG    num_sig_colors;
} BmpHeader;

typedef struct
{    
    PEGUBYTE    Blue;  
    PEGUBYTE    Green;
    PEGUBYTE    Red;
    PEGUBYTE    Count;
} BmpPalEntry;


/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class PegBmpConvert : public PegImageConvert
{
    public:

        PegBmpConvert(PEGUINT Id = 0);
        virtual ~PegBmpConvert(void);

        BmpHeader *GetBmpHeader(void) {return &mBmpHeader;}

       #ifdef PEG_PIC_FILE_MODE
        virtual PEGBOOL GetImageInfo(PegFile *Src, PegImageInfo *info);
       #endif

        virtual PegPixel GetULCColor(void);

       #ifdef PEG_PIC_FILE_MODE
        virtual PEGBOOL ReadImage(PegFile *fd, PEGINT Count = 1);
       #else
        virtual PEGBOOL ReadImage(PEGINT Count = 1);
       #endif

    protected:

    private:

       #ifdef PEG_QUANT
        void CountColors(PegQuant *pQuant);
       #endif

        PEGUBYTE GetBitmapPaddingBytes();
        PEGBOOL ReadBitmapData(void);
        PEGBOOL ReadBitmapHeader();
        void ReadBitmapPalette(void);
        void ReadBitmapScanLine(PEGUBYTE *pPut, PEGUINT Actual);

       #ifndef PEG_PIC_FILE_MODE
        void SkipToBitmapOffset(PEGULONG Offset);
       #endif
        
        BmpHeader mBmpHeader;
        PEGULONG mBytesRead;
};

#endif



